package package01;

/**
 * @Description 消费者
 * @Author zzj
 * @Date 2020/7/24 8:49
 */
public class Consumer implements Runnable {
    @Override
    public void run() {
        // 实例化container
        Container<Bread> container = Container.getInstance();
        // 获取线程名
        String name = Thread.currentThread().getName();
        while (true) {
            try {
                Bread bread = container.consume();
                System.out.println(name + "消费" + bread);
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
